<?php

	namespace Aspic\Model;
	use Aspic as A;

	/**
	 * A DataModel for a Database table.
	 * Added sql types and specific things
	 *
	 * @author Mallory Dessaintes
	 */
	class TableDataModel extends DataModel {
		protected $_tableName;


		public function __construct($tableName, $dataClass = null) {
			parent::__construct($dataClass);
			
			$this->_tableName = $tableName;
			$this->_defaultColParams['sqlType'] = null;
		}
		
		public function getTableName() {
			return $this->_tableName;
		}
		
		public function parseType($type) {
			$colData = array();
			
			if (is_array($type)) {
				$colData['type'] = $type[0];
				
				if (isset($type[1])) {
					$colData['sqlType'] = $type[1];
				}
				
				if (isset($type[2])) {
					$colData['typeLength'] = $type[2];
				}
			}
			else {
				$colData['type'] = $type;
			}
			
			$colData['type'] = strtolower($colData['type']);
			$colData['sqlType'] = strtolower($colData['sqlType']);
			
			return $colData;
		}
		
	}

?>